#include "Bullet.h"


Bullet::Bullet(void)
{
}
void Bullet::setPos(CCSprite* player)
{
	body->setPosition(ccp(player->getPositionX() - 50,player->getPositionY()));
	body2->setPosition(ccp(player->getPositionX() + 50,player->getPositionY()));
}
Bullet::Bullet(CCSprite* player) : GameObj()
{
	body = cocos2d::CCSprite::create("fire1.png");
	body2 = cocos2d::CCSprite::create("fire1.png");
	this->setPos(player);
	body->setScale(0.4f);
	body2->setScale(0.4f);
	addChild(body);
	addChild(body2);
}
void Bullet::update(float deltime,CCSprite* player)
{
	if(isAlive == false)
	{
		isAlive = true;
		this->setPos(player);
	}
	else
	{
		timedelay += deltime;
		if(timedelay >= 0.01f)
		{
			this->setPosition(this->getPosition().x , this->getPosition().y + 10);
			if(this->getPosition().y > CCDirector::sharedDirector()->getVisibleSize().height)
				isAlive = false;
			timedelay = 0.f;
		}
	}
}
Bullet::~Bullet(void)
{
}
 